package cn.szabadsag.pay.service.impl;

import cn.szabadsag.base.constant.PayConstant;
import cn.szabadsag.pay.domain.PayAliPayInfo;
import cn.szabadsag.pay.domain.PayBill;
import cn.szabadsag.pay.mapper.PayAliPayInfoMapper;
import cn.szabadsag.pay.service.IPayService;
import cn.szabadsag.utils.AliPayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author yangcong
 * @date 2022年03月19日 13:17
 * @since
 */
@Service
public class PayServiceImpl implements IPayService {

    @Autowired
    private PayAliPayInfoMapper payAliPayInfoMapper;


    /**
     * 支付方式:内部根据用户选择的支付方式做渠道分发
     */
    @Override
    public String pay(PayBill payBill) {

        switch (payBill.getPayChannel()){
            case PayConstant.ALIPAY:
                PayAliPayInfo payAliPayInfo = payAliPayInfoMapper.loadById(1L);
                //  调用支付宝的工具类
                return AliPayUtils.pay(payBill,payAliPayInfo);

            case PayConstant.WXPAY:
                //  调用微信的工具类
                break;

            case PayConstant.YLPAY:
                //  调用银联的工具类
                break;
        }

        return "";

    }
}
